﻿<nav class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            </a>
            <a class="brand" href="#">LAPI</a>
            <div class="nav-collapse">            
            <ul class="nav">
                <li @isActive(Request.Url.PathAndQuery, "", "")>
                    @Html.ActionLink(
                        linkText: "Haz tu reserva...",
                        actionName: "Home",
                        controllerName: "Home",
                        routeValues: new { },
                        htmlAttributes: null
                    )
                </li>
                @*<li @isActive(Request.Url.PathAndQuery, "", "contacto")>
                <a href="#">Contactar</a>
                </li>  *@          
            </ul>

            <ul class="nav pull-right">
                <li class="divider-vertical"/>

                @if (Session["datosSesion"] == null || !(Session["datosSesion"] is LAPI.Business.DatosSesion))
                {
                        <li @isActive(Request.Url.PathAndQuery, "Login", "Usuario")>
                            @Html.ActionLink(
                                linkText: "Entrar",
                                actionName: "Login",
                                controllerName: "Usuario",
                                routeValues: new { },
                                htmlAttributes: null
                                )
                        </li>
                }
                else
                {
                    LAPI.Business.DatosSesion sesion = (LAPI.Business.DatosSesion)Session["datosSesion"];                 
                    
                        <li class="dropdown">
                            <a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="#">
                                @sesion.getNombreUsuario()
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">
                              
                              @if (sesion.EsAdministradorSistema())
                              {
                                    <li>     
                                        <a class="" href="@Url.Action(actionName: "Gestion", controllerName: "CentroDeportivo")">
                                            <i class="icon-wrench"></i>
                                            administración de Centros Deportivos
                                        </a>                                                           
                                    </li>
                                    <li>     
                                        <a class="" href="@Url.Action(actionName: "Gestion", controllerName: "Deporte")">
                                            <i class="icon-wrench"></i>
                                            administración de Deportes
                                        </a>                                                           
                                    </li>
                                    <li>     
                                        <a class="" href="@Url.Action(actionName: "Gestion", controllerName: "Usuario")">
                                            <i class="icon-wrench"></i>
                                            administración de Usuarios
                                        </a>                                                           
                                    </li>
                                    <li>     
                                        <a class="" href="@Url.Action(actionName: "GestionUsuarioAdministrador", controllerName: "Permisos")">
                                            <i class="icon-wrench"></i>
                                            administración de Usuarios Administradores
                                        </a>                                                           
                                    </li>
                              }
                              else if (sesion.EsAdministradorPistas())
                              {
                                    <li>     
                                        <a class="" href="@Url.Action(actionName: "Gestion", controllerName: "Pista")">
                                            <i class="icon-wrench"></i>
                                            administración de Pistas
                                        </a>                                                           
                                    </li>

                              }
                              else if (sesion.EsUsuario())
                              {
                                    <li>     
                                        <a class="" href="@Url.Action(actionName: "MisReservas", controllerName: "Reservas")">
                                            <i class="icon-ok-circle"></i>
                                            ver mis reservas
                                        </a>                                                           
                                    </li>
                              }
                                
                                <li class="divider"></li>
                                
                                <li>     
                                    <a class="" href="@Url.Action(actionName: "Perfil", controllerName: "Usuario")">
                                        <i class="icon-user"></i>
                                        ver perfil usuario
                                    </a>                                                           
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <a class="" data-toggle="modal" data-target="#logOut">Cerrar sesión</a>                                                         
                                </li>
                            </ul>
                        </li>
                }
            </ul>                    
            </div>
        </div>
    </div>
</nav>

@LogoutModal()
         



<!-- HELPERS -->
@helper isActive(String url, String action, String controller)
    {
        String[] urlSegmentada = url.Split('/');

        if (urlSegmentada.Length == 2 && action.Equals("") && controller.Equals(""))
        {
            @:class="active"
        }
        else if (urlSegmentada.Length == 3 && controller.Equals(urlSegmentada.GetValue(1)) && action.Equals(urlSegmentada.GetValue(2)))
        {
            @:class="active"
        }
    }
@helper LogoutModal()
    {
        <div class="modal hide fade" id="logOut">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">x</button>
                <h3>Cerrando sesión...</h3>
            </div>
            <div class="modal-body">
                <p>¿Desea cerrar la sesión?</p>
            </div>
            <div class="modal-footer">
                <a href="#" class="btn btn-success" onclick="closeLogOut();">Continuar sesión</a>
                <a href="#" class="btn btn-primary" onclick="cerrarSesion();">Cerrar sesión</a>            
            </div>
        </div>  
    }    




